﻿//
// Lightbox Gallery Module for DotNetNuke
// Project Contributors - Will Strohl (http://www.WillStrohl.com), Armand Datema (http://www.schwingsoft.com)
//
//Copyright (c) 2009-2013, Will Strohl
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are 
//permitted provided that the following conditions are met:
//
//Redistributions of source code must retain the above copyright notice, this list of 
//conditions and the following disclaimer.
//
//Redistributions in binary form must reproduce the above copyright notice, this list 
//of conditions and the following disclaimer in the documentation and/or other 
//materials provided with the distribution.
//
//Neither the name of Will Strohl, Armand Datema, Lightbox Gallery, nor the names of its contributors may be 
//used to endorse or promote products derived from this software without specific prior 
//written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
//EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
//OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
//SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
//TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
//BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
//CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
//DAMAGE.
//

//INSTANT C# NOTE: Formerly VB project-level imports:
using System;
using System.Collections.Generic;
using DotNetNuke.Services.Exceptions;

namespace WillStrohl.Modules.Lightbox
{

	public sealed class SettingInfoCollection : List<SettingInfo>
	{

#region  Constructors 

		public SettingInfoCollection() : base()
		{
		}

		public SettingInfoCollection(int capacity) : base(capacity)
		{
		}

		public SettingInfoCollection(IEnumerable<SettingInfo> collection) : base(collection)
		{
		}

#endregion

		public void Fill(System.Data.IDataReader dr)
		{
			try
			{
				while (dr.Read())
				{
					var obj = new SettingInfo();
					if (dr[SettingInfoMembers.SettingIdField] != null)
					{
						obj.SettingId = int.Parse(dr[SettingInfoMembers.SettingIdField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.LightboxIdField] != null)
					{
						obj.LightboxId = int.Parse(dr[SettingInfoMembers.LightboxIdField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.PaddingField] != null)
					{
						obj.Padding = int.Parse(dr[SettingInfoMembers.PaddingField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.MarginField] != null)
					{
						obj.Margin = int.Parse(dr[SettingInfoMembers.MarginField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.OpacityField] != null)
					{
						obj.Opacity = bool.Parse(dr[SettingInfoMembers.OpacityField].ToString());
					}
					if (dr[SettingInfoMembers.ModalField] != null)
					{
						obj.Modal = bool.Parse(dr[SettingInfoMembers.ModalField].ToString());
					}
					if (dr[SettingInfoMembers.CyclicField] != null)
					{
						obj.Cyclic = bool.Parse(dr[SettingInfoMembers.CyclicField].ToString());
					}
					if (dr[SettingInfoMembers.OverlayShowField] != null)
					{
						obj.OverlayShow = bool.Parse(dr[SettingInfoMembers.OverlayShowField].ToString());
					}
					if (dr[SettingInfoMembers.OverlayOpacityField] != null)
					{
						obj.OverlayOpacity = decimal.Parse(dr[SettingInfoMembers.OverlayOpacityField].ToString(), System.Globalization.NumberStyles.Float);
					}
					if (dr[SettingInfoMembers.OverlayColorField] != null)
					{
						obj.OverlayColor = dr[SettingInfoMembers.OverlayColorField].ToString();
					}
					if (dr[SettingInfoMembers.TitleShowField] != null)
					{
						obj.TitleShow = bool.Parse(dr[SettingInfoMembers.TitleShowField].ToString());
					}
					if (dr[SettingInfoMembers.TitlePositionField] != null)
					{
						obj.TitlePosition = dr[SettingInfoMembers.TitlePositionField].ToString();
					}
					if (dr[SettingInfoMembers.TransitionField] != null)
					{
						obj.Transition = dr[SettingInfoMembers.TransitionField].ToString();
					}
					if (dr[SettingInfoMembers.SpeedField] != null)
					{
						obj.Speed = int.Parse(dr[SettingInfoMembers.SpeedField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.ChangeSpeedField] != null)
					{
						obj.ChangeSpeed = int.Parse(dr[SettingInfoMembers.ChangeSpeedField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.ShowCloseButtonField] != null)
					{
						obj.ShowCloseButton = bool.Parse(dr[SettingInfoMembers.ShowCloseButtonField].ToString());
					}
					if (dr[SettingInfoMembers.ShowNavArrowsField] != null)
					{
						obj.ShowNavArrows = bool.Parse(dr[SettingInfoMembers.ShowNavArrowsField].ToString());
					}
					if (dr[SettingInfoMembers.EnableEscapeButtonField] != null)
					{
						obj.EnableEscapeButton = bool.Parse(dr[SettingInfoMembers.EnableEscapeButtonField].ToString());
					}
					if (dr[SettingInfoMembers.OnStartField] != null)
					{
						obj.OnStart = dr[SettingInfoMembers.OnStartField].ToString();
					}
					if (dr[SettingInfoMembers.OnCancelField] != null)
					{
						obj.OnCancel = dr[SettingInfoMembers.OnCancelField].ToString();
					}
					if (dr[SettingInfoMembers.OnCompleteField] != null)
					{
						obj.OnComplete = dr[SettingInfoMembers.OnCompleteField].ToString();
					}
					if (dr[SettingInfoMembers.OnCleanupField] != null)
					{
						obj.OnCleanup = dr[SettingInfoMembers.OnCleanupField].ToString();
					}
					if (dr[SettingInfoMembers.OnClosedField] != null)
					{
						obj.OnClosed = dr[SettingInfoMembers.OnClosedField].ToString();
					}
					this.Add(obj);
				}
			}
			catch (Exception ex)
			{
				Exceptions.LogException(ex);
			}
			finally
			{
				if (! dr.IsClosed)
				{
					dr.Close();
				}
			}
		}

	}

}